package edu.inf3.j2ee.entities;

public class Permission {

	public static final String PERM_READALL = "READALL";
	public static final String PERM_WRITEALL = "WRITEALL";
	public static final String PERM_READOWN = "READOWN";
	public static final String PERM_WRITEOWN = "WRITEOWN";
	
	public static final String ON_BULLETINS = "Bulletins";
	public static final String ON_ABSENCES = "Absences";
	public static final String ON_MARKS = "Marks";
	public static final String ON_WEIGHTING = "Weighting";
	public static final String ON_STUDENTS = "Students";
	public static final String ON_COURSES = "Courses";
	public static final String ON_STATISTICS = "Statistics";
	
	private String permission;
	private String target;
	
	public Permission (String permission, String target){
		this.permission = permission;
		this.target = target;
	}
	
	public String getPermission() {
		return permission;
	}
	public String getTarget() {
		return target;
	}

	public boolean can(String perm){
		return (this.permission == perm);
	}
	
	public boolean canReadAll (){
		return (this.getTarget() == Permission.PERM_READALL);
	}

	public boolean canWriteAll (){
		return (this.getTarget() == Permission.PERM_WRITEALL);
	}
	
	public boolean canReadOwn (){
		return (this.getTarget() == Permission.PERM_READOWN);
	}

	public boolean canWriteOwn (){
		return (this.getTarget() == Permission.PERM_WRITEOWN);
	}
	
}

